import {always, buildMenu} from "@/utils/permission";

export function menuSystem(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0001', 'system', '/system', 'noRedirect', 'Layout', '系统管理', 'system')
    o.children.push(menuSystemDict(permissionCodes))
    o.children.push(menuSystemMdm(permissionCodes))
    o.children.push(menuSystemAuth(permissionCodes))
    o.children.push(menuSystemData(permissionCodes))
    o.children.push(menuSystemApprove(permissionCodes))
    return o
}

function menuSystemDict(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0206', 'dict', 'dict', 'noRedirect', 'ParentView', '数据字典', 'dicts')
    o.children.push(buildMenu(permissionCodes, 'PD0207', 'dictType', 'dictType', '', 'base/dict/dictType/index', '字典类型', 'dict-type'))
    o.children.push(buildMenu(permissionCodes, 'PD0208', 'dictValue', 'dictValue', '', 'base/dict/dictValue/index', '字典值', 'dict-value'))
    return o;
}

function menuSystemMdm(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0002', 'mdm', 'mdm', 'noRedirect', 'ParentView', '主数据', 'disk')
    o.children.push(buildMenu(permissionCodes, 'PD0005', 'file', 'file', '', 'base/mdm/file/index', '文件', 'files'))
    o.children.push(buildMenu(permissionCodes, 'PD0004', 'region', 'region', '', 'base/mdm/region/list', '行政区', 'region'))
    o.children.push(buildMenu(permissionCodes, 'PD0008', 'government', 'government', '', 'base/mdm/government/list', '政府单位', 'gov'))
    o.children.push(buildMenu(permissionCodes, 'PD0076', 'bank', 'bank', '', 'base/mdm/bank/index', '银行', 'bank'))
    o.children.push(buildMenu(permissionCodes, 'PD0034', 'announce', 'announce', '', 'base/mdm/announce/index', '公告', 'announcement'))
    o.children.push(buildMenu(permissionCodes, 'PD0006', 'message', 'message', '', 'base/mdm/message/index', '站内消息', 'letter'))
    o.children.push(buildMenu(permissionCodes, 'PD0077', 'company', 'company', '', 'base/mdm/company/index', '公司', 'company'))
    o.children.push(buildMenu(permissionCodes, 'PD0184', 'airport', 'airport', '', 'base/mdm/airport/index', '机场', 'airport'))
    return o;
}

function menuSystemAuth(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0003', 'auth', 'auth', 'noRedirect', 'ParentView', '组织', 'permission-center')
    o.children.push(buildMenu(permissionCodes, 'PD0009', 'user', 'user', '', 'base/auth/user/index', '用户', 'user'))
    o.children.push(buildMenu(permissionCodes, 'PD0010', 'role', 'role', '', 'base/auth/role/index', '角色', 'role'))
    o.children.push(buildMenu(permissionCodes, 'PD0078', 'permission', 'permission', '', 'base/auth/permission/list', '权限', 'permission'))
    o.children.push(buildMenu(permissionCodes, 'PD0079', 'organization', 'organization', '', 'base/auth/organization/index', '组织架构', 'tree'))
    o.children.push(buildMenu(permissionCodes, 'PD0080', 'userLogin', 'userLogin', '', 'base/auth/userLogin/index', '用户登录记录', 'logininfor'))
    o.children.push(buildMenu(permissionCodes, 'PD0081', 'userVisit', 'userVisit', '', 'base/auth/userVisit/index', '用户访问记录', 'visit'))
    o.children.push(buildMenu(permissionCodes, 'PD0082', 'userFavorite', 'userFavorite', '', 'base/auth/userFavorite/index', '用户收藏记录', 'favorite'))
    return o
}

function menuSystemData(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0083', 'data', 'data', 'noRedirect', 'ParentView', '系统数据', 'system-center')
    o.children.push(buildMenu(permissionCodes, 'PD0172', 'attachment', 'attachment', '', 'base/sys/attachment/index', '附件记录', 'attachment'))
    o.children.push(buildMenu(permissionCodes, 'PD0084', 'recycle', 'recycle', '', 'base/sys/recycle/index', '数据删除记录', 'delete'))
    o.children.push(buildMenu(permissionCodes, 'PD0085', 'sequence', 'sequence', '', 'base/sys/sequence/index', '编码生成记录', 'code'))
    o.children.push(buildMenu(permissionCodes, 'PD0086', 'visit', 'visit', '', 'base/sys/visit/index', '访问记录', 'select'))
    o.children.push(buildMenu(permissionCodes, 'PD0087', 'invoke', 'invoke', '', 'base/sys/invoke/index', '接口调用记录', 'swagger'))
    return o
}

function menuSystemApprove(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0039', 'approve', 'approve', 'noRedirect', 'ParentView', '审批流', 'approval')
    o.children.push(buildMenu(permissionCodes, 'PD0040', 'approveTemplate', 'approveTemplate', '', 'base/approve/approve/index', '审批模版', 'process'))
    o.children.push(buildMenu(permissionCodes, always, 'approveTemplateEdit', 'approveTemplateEdit', '', 'base/approve/approve/edit', '审批模版编辑', ''))
    o.children.push(buildMenu(permissionCodes, 'PD0045', 'approveOrder', 'approveOrder', '', 'base/approve/approveOrder/index', '审批单', 'process-order'))
    o.children.push(buildMenu(permissionCodes, always, 'approveOrderForm', 'approveOrderForm', '', 'base/approve/approveOrder/approve', '审批单处理', ''))
    o.children.push(buildMenu(permissionCodes, 'PD0046', 'approveOrderOper', 'approveOrderOper', '', 'base/approve/approveOrderOper/index', '审批单操作', 'log'))
    o.children.push(buildMenu(permissionCodes, 'PD0047', 'approveOrderTobe', 'approveOrderTobe', '', 'base/approve/approveOrderTobe/index', '审批单待办待阅', 'todo'))
    return o
}
